{include file="$HOME/header.html"}

<div class="admin">
	<form method="post" class="form-x" action="" id="myform">
		<div class="form-group">
			<div class="label">
				<label for="readme">角色名称</label>
			</div>
			<div class="field">
				<input type="text" class="input" name="title" size="50" value="{$row.title}" placeholder="英文字母，数字或下划线，在3-20个字符之间，不区分大小写" data-validate="required:请填写账号"  />
			</div>
		</div>
		
		<div class="form-group">
			<div class="label">
				<label for="readme">权限设置</label>
			</div>
			<div class="label label-text">
				<div class="panel admin-panel">
				<table class="table table-hover">
					<tr>
						<th width="200">菜单名称</th>
						<th>权限</th>
						
					</tr>
					{foreach $menu as $v}
					<tr>
						<td align="center">{$v.title}&nbsp;&nbsp;<i class="icon-angle-down"></i></td>
						<td><a class="button border-blue button-little" href="javascript:;" onclick="group_sd({$v.menu_id})">全选</a></td>
					</tr>
					{foreach $v.child as $d}
					<tr>
						<td align="right">{$d.title}&nbsp;&nbsp;<i class="icon-angle-right"></i></td>
						<td class="group-sd group-id-{$d.top_id}">
							<label>查看<input type="checkbox" name="auth[view][]" value="1"  /></label>
							{if $d.edit}
								<label>添加/修改<input type="checkbox" name="auth[edit][]" value="1" /></label>
							{else}
								<input type="hidden" name="auth[edit][]" value="0" />
							{/if}
							
							{if $d.del}
								<label>删除<input type="checkbox" name="auth[del][]" value="1" /></label>
							{else}
								<input type="hidden" name="auth[del][]" value="0" />
							{/if}
							<input type="hidden" name="auth[menu_id][]" value="{$d.menu_id}" />
						</td>
					</tr>
					{/foreach}
					{/foreach}
				</table>
				</div>
			</div>
		</div>
		
		<div class="form-button">
			<input type="hidden" name="_method" value="put" />
			<input type="hidden" name="_forward" value="{asForward($row,'Group')}" />
			<button class="button bg-main" type="submit" id="mysubmit">保存</button>
		</div>
		

		
	</form>
	
	<script>
		$(function(){
			
			//提交数据
			$("#mysubmit").click(function(){
				$("#myform").putData();
				return false;
			})
			
		})
		function group_sd(id)
		{
			var obj = $(".group-id-"+id);
			var sd = obj.data("sd");
			if(!sd){
				sd = true;
				obj.find('input[type="checkbox"]').prop("checked",true);
			}else{
				sd = false;
				obj.find('input[type="checkbox"]').prop("checked",false);
			}
			obj.data("sd",sd);
			
		}
		
	</script>
</div>
{include file="$HOME/footer.html"}